package com.xintoucloud.pbs.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.xintoucloud.pbs.dao.RolePermissionDao;
import com.xintoucloud.pbs.entity.RolePermission;
@Repository
public class RolePermissionDaoImpl implements RolePermissionDao{
	@Autowired
	private SessionFactory sessionFacaory;
	
	@SuppressWarnings("unchecked")
	@Override
	public List<RolePermission> list() {
		return sessionFacaory.getCurrentSession().createQuery("from RolePermission").list();
	}

	@Override
	public Serializable save(RolePermission rolePermission) {
		return sessionFacaory.getCurrentSession().save(rolePermission);
	}

	@Override
	public RolePermission getOne(int id) {
		return sessionFacaory.getCurrentSession().get(RolePermission.class, id);
	}

	@Override
	public void delete(int id) {
		sessionFacaory.getCurrentSession().delete(getOne(id));
	}

	
}
